﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.Calibration.CUiCalibrationErrorDlg
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using DnProcessSimulateCommands.Calibration.Resources;
using System;
using System.CodeDom.Compiler;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Tecnomatix.Engineering.Ui.WPF;


namespace DnProcessSimulateCommands.Calibration;

public class CUiCalibrationErrorDlg : TxWindow, IComponentConnector
{
  internal System.Windows.Controls.Image WarningIcon;
  internal TextBox errorTextBox;
  private bool _contentLoaded;

  public CUiCalibrationErrorDlg(CApCalibrationSetsModel csm)
  {
    this.InitializeComponent();
    this.SemiModal = true;
    this.WarningIcon.Source = (ImageSource) System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(SystemIcons.Error.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
    this.errorTextBox.Text = "";
    foreach (CApCalibrationSet calibrationSet in (Collection<CApCalibrationSet>) csm.CalibrationSets)
    {
      bool flag1 = CApCalibrationSet.MissingDevices.ContainsKey(calibrationSet.Id);
      bool flag2 = CApCalibrationSet.MissingTargetObjects.ContainsKey(calibrationSet.Id);
      bool flag3 = CApCalibrationSet.MissingLocations.ContainsKey(calibrationSet.Id);
      if (flag1 | flag2 | flag3)
      {
        TextBox errorTextBox1 = this.errorTextBox;
        errorTextBox1.Text = $"{errorTextBox1.Text}{string.Format(CalibrationResources.CALIBRATION_MISSING_OBJECTS_CALIBRATION_SET, (object) calibrationSet.Name)}\n";
        if (flag1)
        {
          TextBox errorTextBox2 = this.errorTextBox;
          errorTextBox2.Text = $"{errorTextBox2.Text}{CalibrationResources.CALIBRATION_MISSING_OBJECTS_DEVICE}\n";
          TextBox errorTextBox3 = this.errorTextBox;
          errorTextBox3.Text = $"{errorTextBox3.Text}{CApCalibrationSet.MissingDevices[calibrationSet.Id]}\n";
        }
        if (flag2)
        {
          TextBox errorTextBox4 = this.errorTextBox;
          errorTextBox4.Text = $"{errorTextBox4.Text}{CalibrationResources.CALIBRATION_MISSING_OBJECTS_TARGET_OBJECTS}\n";
          foreach (string str in CApCalibrationSet.MissingTargetObjects[calibrationSet.Id])
          {
            TextBox errorTextBox5 = this.errorTextBox;
            errorTextBox5.Text = $"{errorTextBox5.Text}{str}\n";
          }
        }
        if (flag3)
        {
          TextBox errorTextBox6 = this.errorTextBox;
          errorTextBox6.Text = $"{errorTextBox6.Text}{CalibrationResources.CALIBRATION_MISSING_OBJECTS_LOCATIONS}\n";
          foreach (string str in CApCalibrationSet.MissingLocations[calibrationSet.Id])
          {
            TextBox errorTextBox7 = this.errorTextBox;
            errorTextBox7.Text = $"{errorTextBox7.Text}{str}\n";
          }
        }
        this.errorTextBox.Text += "\n";
      }
    }
  }

  private void CloseButton_Click(object sender, RoutedEventArgs e) => ((Window) this).Close();

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  public void InitializeComponent()
  {
    if (this._contentLoaded)
      return;
    this._contentLoaded = true;
    Application.LoadComponent((object) this, new Uri("/DnProcessSimulateCommands;component/calibration/cuicalibrationerrordlg.xaml", UriKind.Relative));
  }

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  [EditorBrowsable(EditorBrowsableState.Never)]
  void IComponentConnector.Connect(int connectionId, object target)
  {
    switch (connectionId)
    {
      case 1:
        this.WarningIcon = (System.Windows.Controls.Image) target;
        break;
      case 2:
        this.errorTextBox = (TextBox) target;
        break;
      case 3:
        ((ButtonBase) target).Click += new RoutedEventHandler(this.CloseButton_Click);
        break;
      default:
        this._contentLoaded = true;
        break;
    }
  }
}
